// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init({
  traceUser:true
})
const db = cloud.database()

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  let jieGuo = {}
  db.collection('sentient_beings').where({
    _id:event._id,
    _openid:wxContext.OPENID
  }).update({
    // data 传入需要局部更新的数据
    data: {
      // 表示将 done 字段置为 true
      result:event.result,
      resultText:event.resultText,
    },
    success: function(res) {
      console.log("改",res.data)
      jieGuo=res
    }
  })
  
  return {
    jieGuo,
    event,
    openid: wxContext.OPENID,
    appid: wxContext.APPID,
    unionid: wxContext.UNIONID,
  }
}